package allinpay.yun.demo;

import allinpay.yun.demo.dto.request.member.*;
import allinpay.yun.demo.dto.response.Response;
import allinpay.yun.demo.dto.response.returnvalue.member.*;

/**
 * @author: lijin
 * @date: 2018年11月22日
 */
public class AllinpayServiceImpl {

    private AllinpayClient allinpayClient;

    public AllinpayServiceImpl(AllinpayClient allinpayClient) {
        this.allinpayClient = allinpayClient;
    }

    /**
     * 创建会员
     * @param param
     * @return
     * @throws Exception
     */
    public Response<CreateMemberReturnValue> createMember(CreateMemberReqParam param) throws Exception {
        return allinpayClient.execute(new CreateMemberReq(param), CreateMemberReturnValue.class);
    }

    /**
     * 发送短信验证码
     * @param param
     * @return
     * @throws Exception
     */
    public Response<SendVerificationCodeReturnValue> sendVerificationCode(SendVerificationCodeReqParam param) throws Exception {
        return allinpayClient.execute(new SendVerificationCodeReq(param), SendVerificationCodeReturnValue.class);
    }

    /**
     * 绑定手机
     * @param param
     * @return
     * @throws Exception
     */
    public Response<BindPhoneReturnValue> bindPhone(BindPhoneReqParam param) throws Exception {
        return allinpayClient.execute(new BindPhoneReq(param), BindPhoneReturnValue.class);
    }

    /**
     * 修改绑定手机（短信验证码确认）
     * @param param
     * @return
     * @throws Exception
     */
    public Response<ChangeBindPhoneReturnValue> changeBindPhone(ChangeBindPhoneReqParam param) throws Exception {
        return allinpayClient.execute(new ChangeBindPhoneReq(param), ChangeBindPhoneReturnValue.class);
    }

    /**
     * 个人实名认证
     * @param param
     * @return
     * @throws Exception
     */
    public Response<SetRealNameReturnValue> setRealName(SetRealNameReqParam param) throws Exception {
        return allinpayClient.execute(new SetRealNameReq(param), SetRealNameReturnValue.class);
    }

    /**
     * 获取会员信息
     * @param param
     * @return
     * @throws Exception
     */
    public Response<GetMemberInfoReturnValue> getMemberInfo(GetMemberInfoReqParam param) throws Exception {
        return allinpayClient.execute(new GetMemberInfoReq(param), GetMemberInfoReturnValue.class);
    }

    /**
     * 查询卡 bin
     * @param param
     * @return
     * @throws Exception
     */
    public Response<GetBankCardBinReturnValue>  getBankCardBin(GetBankCardBinReqParam param) throws Exception {
        return allinpayClient.execute(new GetBankCardBinReq(param), GetBankCardBinReturnValue.class);
    }

    /**
     * 请求绑定银行卡
     * @param param
     * @return
     * @throws Exception
     */
    public Response<ApplyBindBankCardReturnValue>   applyBindBankCard (ApplyBindBankCardReqParam param) throws Exception {
        return allinpayClient.execute(new ApplyBindBankCardReq(param), ApplyBindBankCardReturnValue.class);
    }

    /**
     * 确认绑定银行卡
     * @param param
     * @return
     * @throws Exception
     */
    public Response<BindBankCardReturnValue>   bindBankCard (BindBankCardReqParam param) throws Exception {
        return allinpayClient.execute(new BindBankCardReq(param), BindBankCardReturnValue.class);
    }

    /**
     * 查询绑定银行卡
     * @param param
     * @return
     * @throws Exception
     */
    public Response<QueryBankCardReturnValue>   queryBankCard (QueryBankCardReqParam param) throws Exception {
        return allinpayClient.execute(new QueryBankCardReq(param), QueryBankCardReturnValue.class);
    }

    /**
     * 解绑绑定银行卡
     * @param param
     * @return
     * @throws Exception
     */
    public Response<UnbindBankCardReturnValue>   unbindBankCard (UnbindBankCardReqParam param) throws Exception {
        return allinpayClient.execute(new UnbindBankCardReq(param), UnbindBankCardReturnValue.class);
    }




}
